import { request } from '@/utils/request';
import { PageParams } from "@/api/model/pageParams";

const page = async (params: PageParams) => {
    return request.post({
        url: '/sysRole/page',
        data: params
    });
}

const insertApi = async (data: any) => {
    return request.post({
        url: '/sysRole/insert',
        data
    });
}

const updateApi = async (data: any) => {
    return request.post({
        url: '/sysRole/update',
        data
    });
}

const deleteById = async (id: string) => {
    return request.get({
        url: `/sysRole/delete/${id}`,
    });
}

const getPermissions = async (roleId: string) => {
    return request.get({
        url: `/sysRole/getPermissions/${roleId}`,
    });
}

const getOptions = async () => {
    return request.get({
        url: `/sysRole/roleOptions`,
    });
}

const roleCheck = async (params: { roleId: string; check: boolean; permissionIds: string[] }) => {
    return request.post({
        url: `/sysRole/check`,
        data: params
    });
}

export {
    page,
    getOptions,
    insertApi,
    updateApi,
    deleteById,
    getPermissions,
    roleCheck
}
